import { getCurrentInstance, ref } from "vue";
import { LocationQueryRaw } from "vue-router";
import { RouterName } from "@/enums";

interface routerOptions {
    path?: string;
    query?: LocationQueryRaw;
}

export default function () {
    const { proxy } = getCurrentInstance();
    function changeIndex(value:any) {
        proxy.$store.commit("setActiveNavName",value);
    }

    // 路由管理
    function routerManager(routerName: string | number, options: routerOptions) {
        switch (routerName) {
            case RouterName.Home:
            case RouterName.Content:
            case RouterName.SignIn:
            default:
                proxy.$router.push({ path: options.path });
                break;
        }
    }

    return {
        routerManager,
        changeIndex
    };
}
